/* ====================================== api 配置  ====================================== */
const env = process.env.NODE_ENV === 'development';	// 是否为开发环境

const exist = str => window.location.origin.indexOf(str) >= 0

const reportUrl_1 = 'http://reports.norsonmed.com:8900/reviewer?update=1'
const reportUrl_2 = 'http://reports.norsonmed.com:8300?update=1'
const reportPath  = 'http://reports.norsonmed.com:8900'
const uploadUrl	  = 'http://resource.norsonmed.com:8008'
const COVIDUrl_1  = 'http://cv2019test.norsonmed.com/'
const COVIDUrl_2  = 'http://cv2019.norsonmed.com:8008/'
const companySelect = true
const apis = ['http://2021.lis.norsonmed.com:8100/api/']

const data = {
	asyn	: { type:0, name:'异步版', 	api:'http://mapi.norsonmed.com:802/api/', 		host:'//mapi.norsonmed.com/', 		uploadUrl, reportUrl: reportUrl_2, companySelect, COVIDUrl:COVIDUrl_1, apis },
	dev 	: { type:0, name:'开发版', 	api:'http://192.168.0.106:6400/api/', 			host:'//192.168.0.106:8400', 		uploadUrl, reportUrl: reportUrl_2, companySelect, COVIDUrl:COVIDUrl_1, apis }, 
	test 	: { type:1, name:'测试版', 	api:'http://test.norsonmed.com:890/api/', 		host:'//test.norsonmed.com', 		uploadUrl, reportUrl: reportUrl_2, companySelect, COVIDUrl:COVIDUrl_1, apis },
	pre 	: { type:3, name:'预发布', 	api:'http://prelis.norsonmed.com:8900/api/', 	host:'//prelis.norsonmed.com', 		uploadUrl, reportUrl: reportUrl_2, companySelect, COVIDUrl:COVIDUrl_1, apis },
	nslis	: { type:2, 				api:'http://mapi.norsonmed.com:802/api/', 		host:'//nslis.norsonmed.com', 		uploadUrl, reportUrl: 'http://rplis.norsonmed.com', companySelect, apis },
	preview : { type:2, name:'预览版', 	api:'http://preview.norsonmed.com:8900/api/', 	host:'//preview.norsonmed.com', 	uploadUrl, reportUrl: reportUrl_1, reportPath, companySelect, COVIDUrl:COVIDUrl_2, apis },
	release : { type:2, name:'正式版', 	api:'http://lis.norsonmed.com:8900/api/', 		host:'//lis.norsonmed.com', 		uploadUrl, reportUrl: reportUrl_1, reportPath, companySelect, COVIDUrl:COVIDUrl_2, apis }
}

let config = data.pre

if( exist('localhost') || exist('192.168.110.211') || exist('mapi.norsonmed.com') ){					// 开发环境
	config = data.dev		
}else{						// 打包环境
	for( let i in data ){
		const host = data[i].host
		if( exist( host ) ){ config = data[i] }
	}
}

const api = window.localStorage.getItem('api')

if( api ) {
	config.api = api
}

config.apis.unshift(config.api)

window.globalConfig = config
/* ====================================== 全局变量配置  ====================================== */
module.exports = {
	// _api: () => {
	// 	let stack = [ ] 
	// 	if( exist('preview.norsonmed.com') || exist('lis.norsonmed.com') || development ){
	// 		stack = [ _api.preview, _api.release ]
	// 	}else if( exist('prelis.norsonmed.com') ){
	// 		stack = [ _api.pre, _api.preview, _api.release ]
	// 	}else{
	// 		stack = [ _api.asyn, _api.dev, _api.test, _api.pre ]
	// 	}
	// 	return stack
	// },
	// api:getApi, 	
	env, 					// 环境变量
	contentType	: 0,		// Content-type 数据传输类型
	pageSize	: 20,
	getEnv 		: () => {
		// const api = getApi()
		// if(api.indexOf('mapi.norsonmed.com') > -1){			// 开发
		// 	return 0
		// }else if(api.indexOf('test.norsonmed.com') > -1){ 	// 测试
		// 	return 1
		// }else if(api.indexOf('prelis.norsonmed.com') > -1){	// 预发布
		// 	return 3
		// }else{				// 正式
		// 	return 2
		// }
		return window.globalConfig.type
	},
	// uploadUrl: 'http://resource.norsonmed.com',// 图片、pdf上传地址 2021-10-21  --马婷
	// reportUrl: type => type === 2 ? 'http://reports.norsonmed.com:8900/reviewer?update=1&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzeXN0ZW0iLCJpYXQiOjE2MzcwMjc0MDMsImV4cCI6NDc0NzQyNzQwMywibmJmIjoxNjM3MDI3NDAzLCJzdWIiOiJub3Jzb24tcHJldmlldyIsImp0aSI6Ii05OTk5OTkifQ.xhNTfmwudvLwaUfcKxme_lR4XU2E88-yWwtPVU-G2MY' : 'http://reports.norsonmed.com:8300?update=1', // 报告单地址 --伍智睿
}